#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
'''
@author: yuejl
@application:
@contact: lewyuejian@163.com
@file: get_token.py
@time: 2021/8/22 0022 20:19
@desc:
'''
from common import BASE_PATH
from common.load_file import load_file
from listener.takes import use_mapping
from common.httpclient import HttpClient
from common.base.api_client_host import ReadclientHost
from common.parser import parser_test_step_data


class WeChat:
    yaml_data = load_file('test_demo.yml', BASE_PATH)
    data = parser_test_step_data('get_access_token',yaml_data)[0]
    print(data)
    _api_client = ReadclientHost()

    @use_mapping('access_token')
    def get_token(self):
        print(type(self.data))
        resp = self._api_client.doRequest.send_request_v2(self.data)
        return resp.json()

    def get_token_01(self):
        url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken'
        method = 'get'
        body = {
            'corpid': 'wwb4f39b63b59a8a3a',
            'corpsecret': 'Oyc2BalKGSP1KCmdld0P2pSBDaXSeNrHYEwKX8V4sB8'
        }
        from common.httpclient import HttpClient
        resp = HttpClient().send_request_mode(url, method, params=body)
        return resp.json()

if __name__ == '__main__':
    a = WeChat().get_token()
    print(a)